﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace frm_timkiem.DataAccess
{
    class TimKiemData
    {
        sqlDataProvider sdp = new sqlDataProvider();
        public DataTable Thongke_an_uong()
        {
            SqlCommand cmd = new SqlCommand("Select STT, Mathang, ĐVT, Giaban, Tienban, Gianhap, Tiennhap, Lai, PhantramDoanhthu from Thongke_an_uong");
            sdp.Load(cmd);
            return sdp;
        }
        public void Update()
        {
            sdp.Update();
        }
        public DataTable TimKiem(String txtMatHang, String p1, String txtSoLuong)
        {
            SqlCommand cmd = new SqlCommand();
            String sql = "Select Mathang, ĐVT, Giaban, Tienban, Gianhap, Tiennhap, Lai, PhantramDoanhthu from Thongke_an_uong where Mathang=@mathang";
            cmd.Parameters.Add("mathang", SqlDbType.NVarChar, 50).Value = txtMatHang;
            if (p1 != "NONE")
            {
                sql += p1 + " SOLUONG = @soluong";
                cmd.Parameters.Add("soluong",SqlDbType.Int).Value=Convert.ToInt32(txtSoLuong);
            }
            cmd.CommandText = sql;
            sdp.Load(cmd);
            return sdp;
        }
    }
}
